home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-15
/
portest2.zip
/
TESTPORT.DOC
< prev
Wrap
Text File
|
1992-09-17
|
25KB
|
510 lines
Slickware is Copy(c)right 1989,1992 by Gary M. Raymond, New Orleans, La.
Slick Port Modem Register Test Program V1.1 by Gary M. Raymond
Simple <Software> Company
HOME of SlickWare
Gary M. Raymond
P.O.Box 8184
New Orleans, La. 70182
(504) 288-6550
Compuserve 70613,3165
Files Provided:
====================================================================
TESTPORT.COM Serial Port Test Utility.
TESTPORT.DOC This document.
TestPort will run on just about any version of DOS and with any
amount of RAM. If nothing else, TestPort will assist you in learning
more about serial communications and understanding your modem. Having
written and supported several terminal programs over the past seven
years, I have long ago realized that most problems involving terminal
software are actually modem or modem configuration problems. This
utility should take some of the mystery away from configuring,
understanding, and diagnosing serial communications hardware. If for
no other reason than curiosity, you owe it to your modem to use
TestPort at least once and read through this file. TestPort was
written in ASIC, and, I will gladly supply the source code with your
registration, if requested.
====================================================================
TestPort is a basic, easy to use, modem diagnostic tool. Although the
information TestPort provides will at first be seemingly cryptic to
the novice user, it can easily be learned and put to good use. Bit
mapping the modem registers provides a wealth of information about
the state of your modem. Your modem is both configured and monitored
through these registers or electronic switches. Everything from baud
rate to data parity is determined by the one (on) or zero (off) bit
settings in these registers. Particular register bits are also used
to inform the terminal program that a character has arrived or is
ready to be transmitted along with numerous other useful information.
According to the IBM scheme of things, you could have as many as
65,536 port addresses. These ports have an address in the hardware
set up according to IBM's scheme. Each address points to a one byte
location called a base address. Since we can both set and retrieve
bits in these bytes we refer to them as maskable base registers. Each
of the next subsequent nine bytes (BASE+1, BASE+2 etc) form that
ports general register set as outlined in the text below. Serial
communication ports begin with COM Port number one (COM1) with an
address assigned by IBM as decimal 1016 or 3F8 hex. Hence, the
address for the COM1 port register is 3F8. This is the place where a
byte of data is received (3F8 - Received Data Register) or sent (3F8
- Transmitter Holding Register) depending on requirements at the
moment. Therefore the base address allows indirect access to both the
THR and RDR (plus BRDL when bit 7 of LCR is set). The next register
(the IER) is located at this base address plus one, (3F8 + 1 = 3F9)
and so on.
There are two general methods of obtaining bytes of data from a
serial port after it has been set up. The first involves stoping
every so often and looking to see if a byte has arrived, and if so,
taking it. This method of polling the modem registers is ok when
working at very slow baud rates. Polling is the method used by the
PC's Basic Input Output Service (BIOS firmware.) Unfortunately, if a
byte of data arrives before we have had a change to remove the
previous one, information can be lost. To overcome this drawback of
polling we can force the PC to react to the arrival of a byte by
removing and saving it in a special storage area until we have time
to use it. This is done by designing a special Interrupt Service
Routine (ISR) that will be activated instantly (no matter what else
the PC may be doing) to collect and store the byte of data. This is
referred to as an "interrupt on receive" terminal program, such as
our product, SLICK terminal.
There are many things that can go wrong when installing a modem
on your computer. Usually, problems are evenly divided between
hardware and software configuration errors. In general, the modem
itself must be mechanically set, via jumper pins or dip switches,
to address whatever available serial port is usable on your PC.
The selected port must also be paired with an interrupt request line
(IRQ). Note, no two serial devices (examp: modem and mouse) may share
actively the same serial port IRQ address. Some modems force, or
allow you to force, certain register bits either high (1) or low (0)
in lieu of preferred software control. TestPort is useful in
EXAMINING all of the register settings that occur as a results of
these various configurations. Improper configuration of software is
another problem. Here, there are generally three areas of trouble.
Improper comm port, interrupt and modem command (initialization)
string settings. So, to review, One: the serial services must first
be available on the PC. Two: both the modem and terminal software
must agree in settings with the PC hardware you are attempting to
access. And finally, the modem initialization command string must
correctly complete the job of setting any other registers that
require attention, such as setting FAX mode on or off, hardware error
correction enabled or disabled, etc. etc. For what its worth, just
one wrong AT command in the string will cause the entire string to
FAIL. So, if your particular brand modem does not use &D1 (set dtr)
as an example, and, it is inserted into your complete string, such as
ATM1S0=0V1X4&D1S7=45, then the entire string will fail returning an
error message, leaving your modem still waiting to be configured.
====================================================================
USING TestPort's register mapping ability:
To run TestPort with mapping action, you must pass the active port
number via a command parameter. TestPort will work on the four
standard IBM default ports of 1 (3F8), 2 (2F8), 3 (3E8), and 4 (2E8).
Let's assume your modem is configured to operate using COM2. Type
TESTPORT 2 at the DOS prompt. In most cases, you will really want to
do this while your terminal program is active. You do this by
dropping to DOS from within your terminal program, then executing
TestPort. Most all Terminal programs have a drop to DOS feature,
although it might be called something else. TestPort does a passive
read only on these registers and therefore will in no way alter or
change their bit settings. By using the drop to dos feature, which
allows the modem code to remain loaded in ram, you eliminate the
possibility that any modem registers will be inadvertently altered,
by your terminal program, before you get to read the registers. Some
terminal programs also have features that allow the naming and
execution of any external dos utility via a combination of trigger
hot keys. This is a MUCH better way of quickly running TestPort.
Don't forget in either case to pass the active port number in use.
(i.e. TESTPORT 2.) If TestPort is executed as an external utility,
screen output data will remain until a key is pressed. This will give
you opportunity to hit Shft PrtSc and save a copy of the screen to
your printer for evaluation and analysis. If you do not have a
printer, you should make a long hand record on paper.
USING TestPort's UART finder:
Running TestPort without a port parameter will cause TestPort to
cycle through the four common UART addresses looking for an active
(U)niversal (A)synchronous (C)ommunications (C)ontroller. (8250 IC)
If active port addresses are located, TestPort will notify you of
those that appeared active. Notice, I said appeared active. It is
possible to have two serial ports but only one terminated to a
modem. The other may be just a jack on the rear of your PC, there
for some later expansion. A simple serial card with its open jack
will still show as an active port.
Screen Output:
------------------------------------------------------------------------
The Correct Syntax is TESTPORT #, (# to test), i.e. TESTPORT 4,
however, TestPort will now try to determine what if any serial
port is responding to TestPort's Inquiries....................
COM1 appears to have an active UART!
COM2 appears to be inactive.
COM3 appears to be inactive.
COM4 appears to have an active UART!
Enter Port# to test or Esc to exit ->
In five seconds type AT <Enter>, active port will echo OK or 0, else Esc!
------------------------------------------------------------------------
Although this kind of information is by far un-conclusive, it does
give you enough insights to continue experimenting. In the case of
the information given above, the modem must be attached to either
COM1 or COM4. To determine which it is, try entering 1 first. If
there is no echoing of your keystroke or an OK reply to AT (the modem
attention command) the probability is COM1 is not the port connected
to your modem. Now try 4. This should test ok! More than likely, COM1
is an extra, as of yet unused, serial adapter.
Although this testing facility is only a raw polling terminal, set to
1200 baud, N81, it can easily be used for simple task, like dialing
out to test other modems etc. Try typing ATH1 and see if you hear
your modem take the line off hook....ATH0 to replace it. Fun hun?
====================================================================
SCREEN GENERATED BY TESTPORT when mapping registers:
When TestPort is run, it produces the following screen, indicating
the various one byte registers that have been read, their decimal,
hex, and (binary) bit map values. It's those bit settings you are
most interested in. The two indirect registers (THR and RDR) read
via the base register are not useful here. However, those two plus
the eight indicated account for the 10 registers of a UART chip.
*******************************************************
Modem Register Bit Map by Gary M. Raymond SSC
Phone (504) 288-6550
Modem Registers Dec Value Hex Value Bit Map
76543210
IER (Int Enable) 0 00 00000000
IIR (Int ID) 1 01 00000001
LCR (Line Control) 3 03 00000011
MCR (Modem Cont) 8 08 00001000
LSR (Line Status) 97 61 01100001
MSR (Modem Status) 48 30 00110000
BRDL (Low Register) 6 06 00000110
BRDH (Hi Register) 0 00 00000000
*******************************************************
Hit Any Key to Exit!
NOTE: Bit positions are read left to right, starting with position
0 (zero) and ending with 7. This accounts for a full byte of
eight bits.
====================================================================
SAMPLE USES for TESTPORT:
Q) My modem wont hang up, what do I look for?
A) Look at bits 0 and 1 of MCR after starting your terminal program
but before dialing a number. They should both be set to 1. If not
check to see if your modem requires external dip switch settings
to force DTR, RTS or software AT commands like &D2 and &C1.
Q) How can I tell if my terminal program is interrupt driven or
a polling BIOS type?
A) Look at bit 0 of IER, it will be set to 1 if the terminal is
interrupt driven. Also, bit 3 of MCR is usually set to 1 as
well. These bits are set to 0 (zero) in a polling terminal.
Q) My modem wont respond on COM2.
A) Run TESTPORT 2. If If you see each modem register returning FF hex
(dec 255 or 11111111 binary) odds are this port is not activated
correctly via pin or dip settings on the modem card. Check your
modem manual for correct pin or dip switch settings.
Q) How can I tell what Baud rate my modem is locked at?
A) First, run TestPort and obtain the BRDL and BRDH register values.
Then cross reference them with the Baud Rate Value chart in this
document file.
Q) Can I use TestPort to place a call to a BBS?
A) Yes, but it's VERY limited as a polling terminal and not intended
for that kind of application. No protocols, no dial directory, no
no nothing, just a bare foot terminal!
Q) My modem and software configured for COM3 is brain dead, can
TestPort help?
A) You bet! Some serial communications software, especially tsr type,
use BIOS services for communicating with the serial ports. BIOS
then depends on DOS to insert the correct port addresses into the
BIOS area of memory. Some versions of DOS fail to place the
default addresses for COM3 and COM4 in the required BIOS area of
memory. TestPort overcomes this limitation by poking ALL of the
IBM default addresses (3F8 - 2F8 - 3E8 - 2E8) into the correct
area of bios memory starting at segment 0040. This feature is
automatic anytime you run TestPort in any mode. To cancel out
these values, you only need reboot the PC. I will also provide a
seperate utility (PCA.COM) that can be used via your autoexec.bat
to insure these addresses are always available after bootup.
Q) My terminal program has a host mode that allows remote access to
DOS via a redirection statement in a batch file. Only guess what?
It locks up my computer. Can TestPort help me?
A) Well, maybe. There are many computers (clones or otherwise) that
just do not take kindly to re-direction. (CTTY COM1 or CTTY > AUX1
type calls) If the reason is due to the problem outlined in the
answer above, TestPort or PCA will solve it. If not, there is
a device driver in the public domain called GateWay that usually
will accept re-direction. It can be found on most BBS'es. One
nice thing about GateWay is it still allows access to the host
keyboard and monitor; simple re-direction does not.
Q) Can I use TestPort to see the default and or active settings
of all registers in my modem?
A) Yes, actually, you can do that with any terminal program. To use
TestPort, type TESTPORT at the dos prompt. Select the active port
number and wait five seconds for the terminal to respond. Type
AT&V then hit enter. On some older modems you cannot dump the
entire register set and you must poll each individually. Say
you want to see the present value in S7, type ATS7? and so on.
Q) My old modem had a volume control on the card. My new one does
not. Can TestPort save my marriage and turn down the volume?
A) Yes, and again, it can also be done with your present terminal.
By default most modems allow the speaker on at full volume. You
can control this by resetting the M and L registers. ATM1 will
turn off the sound after a connect and ATL0 will reduce the volume
to the lowest setting. Of cource, these switches belong together
in your initialization command string. (ATM1L1etc.etc.etc.)
====================================================================
MODEM REGISTER BIT MAP DATA:
For general purpose information, the port addresses of
these registers are as follows:
BASE = COMPORT ADDRESS (COM1 = 3F8h)
Therefore, MCR for COM1 equals 3F8h + 4 or 3FCh
Ten Modem Registers
---------------------------------------------
THR,RDR, *BRDL = BASE
IER, *BRDH = BASE + 1 ; Interrupt Enable Register
IIR = BASE + 2 ; Interrupt Identification Register
LCR = BASE + 3 ; Line Control Register
MCR = BASE + 4 ; Modem Control Register
LSR = BASE + 5 ; Line Status Register
MSR = BASE + 6 ; Modem Satus Register
---------------------------------------------
*requires bit 7 set to 1 in LCR for access
====================================================================
IER BIT MAPPING (Interrupt Enable Register)
---------------------------------------------
BIT Activates Action
0 = Data Received Read RDR
1 = THR empty Output to THR
2 = Data error/break Read LSR
3 = MSR change Read MSR
4 = zero
5 = zero
6 = zero
7 = zero
Although the 8250 Uart has 10 one byte registers, only seven have
direct access, and of the seven, three of these are used
redundantly to gain access to the three non directly accessible
registers. This indirect access is achieved by setting bit 7 of
LSR to 1. Then, the BRDL and BRDH registers are accesses at BASE
and BASE + 1. These two registers are used to lock the port baud
rate. The BRD (Baud Rate Divisor) is a 16 bit number (two bytes)
and therefore requires two (one byte) register access through
BASE and BASE + 1. Interesting enough, the high byte is only
necessary for baud rates of 300 or below. At 1200 or higher BRDH
is set at zero. The formula for calculating the BRD value
demonstrates why.
UART CLOCK SPEED (1.8432mhz)
BRD = ----------------------------
16 x bit transfer rate (not really baud)
1,843,200
BRD = --------- = 256 or 110000000 or 100h
16 x 300
B B
R R
D D
breaking the result into H L
two bytes produces = 1 & 1000000
where BRDH = 1hex and BRDL = 80h (128 dec)
FOR 1200 BAUD:
1,843,200
BRD = --------- = 96 or 1100000 or 60h
16 x 1200
B B
R R
D D
breaking the result into H L
two bytes produces = 0 & 1100000
where BRDH = 0hex and BRDL = 60h (96 dec)
The THR (Transmit Holding Register) and RDR (Received Data Register)
are accessed via the same physical address as the port base address.
Since you cannot in theory send and receive at the same instant, this
little scheme seems ok.
IIR BIT MAPPING (Interrupt Identification Register)
---------------------------------------------
BIT
0 = more than 1 intr has occurred
12 12
1-2 = 00 change in MSR 10 data received
01 THR empty 11 recv error/break
3 = zero
4 = zero
5 = zero
6 = zero
7 = zero
LCR BIT MAPPING (Line Control Register)
---------------------------------------------
BIT 01 01
01 = Data Length 00=5bits 10=7bits
01=6bits 11=8bits
2 = Stop Bits 0=1bit 1=2bits
345 345
345 = Parity 000=NONE 101=MARK
100=ODD 111=SPACE
110=EVEN
6 = Break Condition 0=disabled 1=enabled
7 = Port Toggle 0=Use THR/RDR/IER 1=Use BRDL/BRDH
SAMPLE: Using N parity, 8 data bits and 1 stop bit requires
the LCR register of 00000000 to be then set as follows:
76543210 = bit pattern
11 = 8 bits
0 = 1 stop bit
000 = no parity
0 = break disabled
0 = toggle inactive
----------
00000011 = 3h to send to LCR
Bit 7 of LCR controls the dual function of bits 0 and 1 in the
IER Register and should be set to zero in the above example.
MCR BIT MAPPING (Modem Control Register)
---------------------------------------------
BIT
0 = Set DTR line active
1 = Set RTS line active
2 = USER BIT #1
3 = USER BIT #2
4 = UART loopback
5 = zero
6 = zero
7 = zero
Bit 3 is normally set to 1 for interrupt driven terminal
programs. Most programs force the modem to hang up by setting
bits 0 and 1 to 0. Modem software setup for these first two bits
therefore is usually 1 and 1.
LSR BIT MAPPING (Line Status Register)
---------------------------------------------
BIT
0 = byte in RDR (received)
1 = overrun in RDR
2 = Parity error detected
3 = Framing error (out of sync, no stop bit received)
4 = Break Detect
5 = THR empty
6 = TSR empty (removes char from THR)
7 = Time Out
A communications program usually checks bit 5 here before sending
another character out the base port.
MSR BIT MAPPING (Modem Status Register)
---------------------------------------------
BIT
0 = change in [C]lear [T]o [S]end CTS
1 = change in [D]ata [S]et [R]eady DSR
2 = change in ring indicator RI
3 = change in [D]ata [C]arrier [D]etect DCD
4 = Clear to send ..... [CTS] set high
5 = Data set ready .... [DSR] set high
6 = Ring Indicator .... [RI] set high
7 = Data Carrier detect [DCD] set high
Most BBS programs monitor bit 7 of the MSR to determine
if carrier is lost during a logon.
===================================================================
BAUD RATE DIVISOR (BRD Register) CHART
Bit Rate BRDH BRDL
---------------------------------------
50 09h 00h
110 04h 17h
300 01h 80h
---------------------------------------
1200 00h 60h From 1200 up, BRDH is
2400 00h 30h always set to zero!
4800 00h 18h
9600 00h 0Ch
19200 00h 06h
===================================================================
Registering your copy will help continue the competitive advantages
of providing economical shareware. As an additional bonus, I will
ship you several other useful modem and dos utilities free! If
you have any comments or suggestions about this utility, feel free
to write or call.
Name_____________________________________________________________
Mailing Address__________________________________________________
City & State ___________________________________________________
ZIP _____________________________ Phone _________________________
Send $4 + $1 (ship & hand) check or money order to:
Gary M. Raymond
P.O.Box 8184
New Orleans, La. 70182
504-288-6550
Compuserve 70613,3165
====================================================================
EOF